﻿using PagedList;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WordDocumentGenerator.Library;

namespace GPS.ENTITYS
{
    public class Export_TLHopDongDaoTaoLX
    {
        [Display(Name = "DVGTVT_MA")]
        public string DVGTVT_MA { get; set; }
        public string HV_MA { get; set; }
        public string DATETIME_NOW { get; set; }
        public List<TLHopDongDaoTaoLX> LIST_TLHOPDONGDAOTAO { get; set; }
    }
    public class TLHopDongDaoTaoLX
    {
        public string HOTEN { get; set; }
        public string HV_NGAYSINH { get; set; }
        public string HV_NOITT { get; set; }
        public string HV_KH_MA { get; set; }
        public string HV_DVGTVT_MA { get; set; }
        public string DVGTVT_TEN { get; set; }
        public string DVGTVT_SOGP { get; set; }
        public DateTime? DVGTVT_NGAYGP { get; set; }
        public string DVGTVT_LANHDAO { get; set; }
        public string DVGTVT_ADD { get; set; }
        public string DVGTVT_TEL { get; set; }
        public string DVGTVT_FAX { get; set; }
    }
    public class View_Export_TLHopDongDaoTaoLX
    {
        public int? Page { get; set; }
        public string dDVGTVT_MA { get; set; }
        public string hHV_MA { get; set; }
        public IPagedList<Export_HopDongDaoTaoLX> SearchResults { get; set; }
    }

    public class EXPORTWORD_TLHopDongDaoTaoLX
    {
        public static byte[] EXPORT_OPENDOOR(string templateFileName, object objSource, string docType)
        {
            DocumentGenerationInfo generationInfo = GetDocumentGenerationInfo(docType, "1.0", objSource, templateFileName, false);

            COMMON.ExportCore<Export_TLHopDongDaoTaoLX> docGenerator = new COMMON.ExportCore<Export_TLHopDongDaoTaoLX>(generationInfo);

            return docGenerator.GenerateDocument();
        }
        /// <summary>
        /// Gets the document generation info.
        /// </summary>
        /// <param name="docType">Type of the doc.</param>
        /// <param name="docVersion">The doc version.</param>
        /// <param name="dataContext">The data context.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="useDataBoundControls">if set to <c>true</c> [use data bound controls].</param>
        /// <returns></returns>
        private static DocumentGenerationInfo GetDocumentGenerationInfo(string docType, string docVersion, object dataContext, string fileName, bool useDataBoundControls)
        {
            DocumentGenerationInfo generationInfo = new DocumentGenerationInfo();
            generationInfo.Metadata = new DocumentMetadata
            {
                DocumentType = docType,
                DocumentVersion = docVersion
            };
            generationInfo.DataContext = dataContext;
            generationInfo.TemplateData = File.ReadAllBytes(fileName);
            generationInfo.IsDataBoundControls = useDataBoundControls;

            return generationInfo;
        }

    }
}
